<?php

abstract class BaseMenu
{
    protected $p_controller_id;
    protected $p_action_id;
	protected $controller_id;
	protected $action_id;
	protected $module_id;
	protected $module;
	protected $control;
	//系统权限
	protected $rights;
	//模块权限
	protected $module_rights;
	//用户权限
	protected $act_rights;
	protected $_res = array();
	
	/**
	 * @return $this->_res
	 */
	abstract public function init_menu();
	
	public static function get_instance()
	{
		static $_instance;
		if (is_object($_instance)) {
			return $_instance;
		}
		$_instance = new menu();
		return $_instance;
	}
	
	public function __construct()
	{
		$this->control = Yii::app()->getController();
		$this->controller_id = $this->control->controller_id;
		$this->action_id = $this->control->action_id;
		$this->module_id = $this->control->module_id;
		$this->module = $this->control->module;
		$this->rights = Yii::app()->params->rights['user_rights'];
		$this->module_rights = Yii::app()->params->module_rights;
		$this->act_rights = Yii::app()->user->act_rights;
		//新增匹配栏目列表
		$this->p_controller_id = isset($this->control->actionParams['c']) ? $this->control->actionParams['c'] : $this->controller_id;
		$this->p_action_id = isset($this->control->actionParams['c']) ? $this->controller_id : $this->action_id;
	}
	
	protected function checkRights($rights, $control = null, $action = null, $module = null)
	{
		return $this->control->checkRights($rights, $control, $action, $module);
	}
}